<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>电机测试报告</title>
		<meta name="description" content="电机测试报告">
		<link rel="stylesheet" href="css/AllStyle.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/companydata.js"></script>
		<script type="text/javascript" src="js/data.js"></script>
		<script type="text/javascript" src="js/tmpl.js"></script>
		<style>
			.StockNav ul{
	        padding:2px 0;
	    }
	    .StockNav li:nth-child(2){
            width: 66%;
            white-space: nowrap;
	    }
	    </style>
	</head>
	<body>
		<!-- 页头 -->
		<section>
			<script type="text/javascript">
				AllPageHeader();
			</script>
		</section>

		<!-- 页面  -->
		<section class="AllContent" id="AllContent" style="background-color: #fff;">

			<img id="LoadingImg" style="width: 40%;margin:20px auto;display:block;" src="images/loading5.gif" />

			<div style="width:100%;height:300px;overflow-x: hidden;overflow-y: hidden;margin-top:-20px;">
				<div id="main" style="position:relative;width:100%;min-width:100%;height:300px;"></div>
			</div>
			<div class="text-center">测试次数：<span id="pack_total">330</span></div>
			<!-- 信息 -->
			<div class="dataNav">
				<ul>
					<li style="width:40%">SN码</li>
					<li style="width:30%">参数</li>
					<li style="width:25%">是否合格</li>
				</ul>
			</div>

			<div id="datalist">

			</div>

		</section>

	</body>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/mui.min.js"></script>
	<script type="text/javascript" src="js/echarts.min.js"></script>

	<script type="text/javascript">
		var json = {
			"result": 1,
			"data": [
				{
					"d": "2019-6-1",
					"num": 60
				},
				{
					"d": "2019-6-2",
					"num": 30
				},
				{
					"d": "2019-6-3",
					"num": 80
				},
				{
					"d": "2019-6-4",
					"num": 60
				},
				{
					"d": "2019-6-5",
					"num": 70
				}
				
			],
			"info": {
				"end_time": "2019-06-5",
				"start_time": "2019-06-01"
			},
			"total_results": "330",
			"page_no": "1",
			"page_size": "10",
			"packlist": [{
				"sncode": "8eaf1e7e-76fa-4715-937f-a96f83394a55",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"

			}, {
				"sncode": "d9ed4d3a-c022-42ef-8c6a-d1b5b0b40529",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}, {
				"sncode": "bea1e2e2-ce75-4fcd-800a-34c157f8ada5",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}, {
				"sncode": "17f489a5-5ff9-450b-8297-b8772d4a9a7f",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}, {
				"sncode": "5a10c4bb-0b86-4c35-b40b-f19b040d2d50",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}, {
				"sncode": "e3e8a2cf-5174-42b1-b102-f3bc8e0a4ddd",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}, {
				"sncode": "7ec40e8a-7d3e-4fd5-bc0b-80a9eb4f2829",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}, {
				"sncode": "fb29dcb8-35ca-4311-ac5a-b5a1a72b7dc0",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}, {
				"sncode": "16e53b60-460a-4fef-b402-c229a497be9f",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}, {
				"sncode": "1bc68263-93fe-4baf-a58e-7a1f3bd24138",
				"param": "1001",
				"is_ok": "是",
				"created": "2019-06-04 17:26:41",
				"created_by": "张三"
			}]
		}

		function GetDateStr(AddDayCount) {
			var dd = new Date();
			dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
			var y = dd.getFullYear();
			var m = dd.getMonth() + 1; //获取当前月份的日期
			var d = dd.getDate();
			return y + "-" + m + "-" + d;
		}
		datas = new Array();
		dates = new Array();

		$(function() {
			$('.AllHeader li:eq(1)').text('测试统计')


			//返回首页
			$(".returnhome").on('tap', function() {
				openUrl("supper.html");
			});

			/*遮罩*/
			$('.shadeBack').click(function() {
				$('.eject').hide();
				state = true;
			});

			$('.queryexit').click(function() {
				$('.eject').hide();
				state = true;
			});


			loadpackages();

			var RequestTime = 1,
				page_no = 1,
				cishu = 1,
				intZh = 1,
				ptinfo = 1;
			$("#AllContent").scroll(function() {
				var divHeight = $(this).height();
				var nScrollHeight = $(this)[0].scrollHeight;
				var nScrollTop = $(this)[0].scrollTop;
				var xiami = nScrollTop + divHeight;
				if (nScrollTop + divHeight >= nScrollHeight) {

					if (page_no == 1) {
						var Pages = 2;
					} else {
						Pages = ++page_no
					}

					if (RequestTime == cishu) {
						$('#datalist').append(
							"<img id='LoadingImg1' style='borderTop:3px solid #f3f3f3;width: 20%;margin:0px auto;display: block;' src='images/loading5.gif'><p style='text-align:center;color:#777;padding:0px 0px;'>正在加载...</p>"
						);
						//$(this).animate({scrollTop:xiami},800);
						RequestTime++;
						var ZLength = 330 / 20;
						var Strlength = ZLength.toString();
						intZh = Math.ceil(Strlength);
						if (intZh == 1) {
							intZh++;
						}
						if (intZh == Pages) {
							RequestTime = 0;
							$('#LoadingImg1').next().remove();
							$('#LoadingImg1').remove();
							return;
						} else {

							var packlist = json.packlist;

							UpwardRefresh(packlist);
							showpage(json.total_results, json.page_no, json.page_size, getwindowhref());
							page_no = json.page_no;
							cishu = json.page_no;
						}
					} else if (RequestTime == 0) {
						if (ptinfo == 1) {
							$('#datalist').append(
								"<img id='LoadingImg1' style='borderTop:3px solid #f3f3f3;width: 20%;margin:0px auto;display: block;' src='images/loading5.gif'><p style='text-align:center;color:#777;padding:0px 0px;'>正在加载...</p>"
							);
							$(this).animate({
								scrollTop: xiami
							}, 800);

							setTimeout(function() {
								$('#LoadingImg1').attr('src', 'images/loading5_.jpg');
								$('#LoadingImg1').next().text('没有更多数据...');
							}, 1500);

							setTimeout(function() {
								$('#LoadingImg1').next().hide(500);
								$('#LoadingImg1').hide(500);
							}, 2500);

							ptinfo++;
						}
					}

				}
			});


		});

		function loadpackages() {
			var myChart = echarts.init(document.getElementById('main'));

			document.addEventListener('deviceready', onDeviceReady, true);

			if (json.result == "1") {
				var clist = json.data;
				var packlist = json.packlist;
				if (!empty(clist)) {
					for (var i = 0; i < clist.length; i++) {
						if (!empty(clist[i])) {
							//datts.push(clist[i].d);
							datas.push(clist[i].num);
						}
					}
				}
				var chtml = ''
				$('#LoadingImg').hide();
				if (!empty(packlist)) {
					for (var i = 0; i < packlist.length; i++) {
						if (!empty(packlist[i])) {
							chtml = chtml + '<ul>' +
								'<li style="width:40%;">' + packlist[i].sncode + '</li>' +
								'<li style="width:30%;">' + packlist[i].param + '</li>' +
								'<li style="width:30%;">' + packlist[i].is_ok + '</li>' +
								'</ul>';
						}
					}
				}
				$("#datalist").html(chtml);
				$("#pack_total").html(json.total_results);

				option = {
					tooltip: {
						trigger: 'axis'
					},
					grid: {
						left: '3%',
						right: '4%',
						bottom: '3%',
						containLabel: true
					},
					xAxis: {
						type: 'category',
						boundaryGap: false,
						data: [
							GetDateStr(-7),
							GetDateStr(-6),
							GetDateStr(-5),
							GetDateStr(-4),
							GetDateStr(-3),
							GetDateStr(-2),
							GetDateStr(-1)
						]
					},
					yAxis: {
						type: 'value'
					},
					series: [{
						name: '检验数量',
						type: 'line',
						stack: '总量',
						data: datas
					}]
				};
				myChart.setOption(option);

			}
		}

		function UpwardRefresh(clist) {
			var chtml = '';
			//var chtml = '';
			/*
			"sncode": "1bc68263-93fe-4baf-a58e-7a1f3bd24138",
			"param": "1001",
			"is_ok":"是",
			"created": "2019-01-04 17:26:41",
			"created_by": "张三"
			*/

			if (!empty(clist)) {
				for (var i = 0; i < clist.length; i++) {
					if (!empty(clist[i])) {
						chtml = chtml + '<ul>' +
							'<li style="width:40%;">' + clist[i].sncode + '</li>' +
							'<li style="width:30%;">' + clist[i].param + '</li>' +
							'<li style="width:30%;">' + clist[i].is_ok + '</li>' +
							'</ul>';
					}
				}
			}
			$('#LoadingImg1').next().remove();
			$('#LoadingImg1').remove();
			$("#datalist").append(chtml);
		}



		function onDeviceReady() {
			document.addEventListener("backbutton", onBackKeyDown, false);
		}

		function onBackKeyDown() {
			openUrl("supper.html");
		}
	</script>
</html>
